home *** CD-ROM | disk | FTP | other *** search
/ Precision Software Appli…tions Silver Collection 4 / Precision Software Applications Silver Collection Volume 4 (1993).iso / stats / chadyn.exe / YDISK.C < prev    next >
Text File  |  1988-12-08  |  10KB  |  362 lines

  1. /******************************** YDisk.C:  **********************************/
  2. /*********************** (C) 1986,7,8 by JAMES A. YORKE **********************/
  3.  
  4. #include "yinclud.h"
  5. #include <ctype.h>
  6.  
  7. /* GETDISKFILENAME - take the letters (lower case) and digits out of
  8.  * MapName[] and puts it into DDfile[], substituting caps for lower cases;
  9.  * then ".PIC" is appended; characters other than letters and digits in
  10.  * MapName are ignored, though I guess there cannot be anything else.
  11.  * Note: Unix version does not map upper to lower case.
  12.  */
  13. GetDiskFileName() 
  14. {
  15. #ifndef UNIX
  16.     int     J;
  17.     char   *dfn, ch;
  18. #endif
  19.  
  20.     (void) strcpy(DDfile, DiskFileName);
  21. #ifndef UNIX
  22.     dfn = DiskFileName;
  23.     for(J = 0; J < 8 && (ch = MapName[J]) != '\0'; J++)  {
  24.         if(isalnum(ch))  {
  25.             if(isdigit(ch))
  26.                 *dfn++ = ch;
  27.             else
  28.                 *dfn++ = (islower(ch) ? _toupper(ch) : ch);
  29.         } else
  30.                     *dfn++ = ch;
  31.     }
  32.     (void) strcat(DiskFileName, ".PIC");
  33. #else
  34.     (void) strcat(strcpy(DiskFileName, MapName), ".pic");
  35. #endif
  36.     return;
  37. }
  38.  
  39.  
  40. /* sets the diskdump file name to be the same
  41.  * as MapName except that it ends in .DD instead of the old ending 
  42.  */
  43. NameDDfile() 
  44. {
  45. #ifdef BAD
  46. #ifndef UNIX
  47.     (void) strcat(strcpy(DDfile, MapName), ".DD");
  48. #else
  49.     (void) strcat(strcpy(DDfile, MapName), ".dd");
  50. #endif
  51. #endif /* BAD */
  52.     char *dot,*strcpy();
  53.  
  54.     strcpy(DDfile,DiskFileName);
  55.     dot = DDfile;
  56.     while(*dot != '.' && *dot != '\0') /* find address of point of end 
  57.             of string, whichever comes first */
  58.         dot++;
  59.     dot[0] = '.';
  60.     dot[1] = 'D';
  61.     dot[2] = 'D';
  62.     dot[3] = 0;/* 0 means end of string */
  63.  
  64.     return;
  65. }
  66.  
  67.  
  68. DumpData(fff)            /* THIS COMMENT SEEMS INCORRECT: this takes the
  69.                    file name DiskFileName and puts it in the
  70.                    string DDfile, except with the ending ".DD"
  71.                    plus a 0 for the end of the string; then it
  72.                    dumps the current values with their commands
  73.                    into that diskfile */
  74. FILE * fff;
  75. {
  76.     double  x,
  77.             X,
  78.             yval,        /* Y is global */
  79.             Y;
  80.     int     ss,
  81.             i,
  82.             numL;
  83.  
  84.     fprintf(fff,
  85.             "%s /* process from map menu */\n", MapName);
  86.     if(VertLine != 0)
  87.         fprintf(fff,
  88.                 "VERTLINE  %d /* for basin boundaries */\n", VertLine);
  89.     if(num_lyap != -9999)    /* this should come before dot because "L" sets
  90.                    dot = 0 */
  91.         if(storeNumLyap != 0 || num_lyap != 0) {
  92.             if(num_lyap != 0)
  93.                 numL = num_lyap;
  94.             else
  95.                 numL = storeNumLyap;
  96.             fprintf(fff,
  97.                     "L  %d /* number of Lyapunov exponents */\n", numL);
  98.  
  99.             fprintf(fff,
  100.                     "LYAPTIME  %15.15lf /* for internal use */ \n", lyaptime);
  101.             fprintf(fff,
  102.                     "LYAPSTEP  %15.15lf \n", lyapstep);
  103.             fprintf(fff,
  104.                     "LYAPSUM ");
  105.             for(i = 0; i < numL; i++)
  106.                 /* for re-initializing vector lyapsum  */
  107.                 fprintf(fff, "  %15.15lf \n ", lyapsum[i]);
  108.         }
  109.     fprintf(fff,
  110.             "DOT  %ld /* current dot number */\n", dot);
  111.     if(dots != 100000000)
  112.         fprintf(fff,
  113.                 "DOTS  %ld /* maximum number of dots */\n", dots);
  114.     if(preiter != 0)
  115.         fprintf(fff,
  116.                 "PI  %ld /* Pre-Iterates before plotting */ \n", preiter);
  117.     if(TDFreq != 0)
  118.         fprintf(fff,
  119.                 "TDFREQ  %ld /* dots per TD call: saving picture on disk */\n", TDFreq);
  120.     if(C1 != -9999)
  121.         fprintf(fff,
  122.                 "C1 %15.15lf \n", C1);
  123.     if(C2 != -9999)
  124.         fprintf(fff,
  125.                 "C2  %15.15lf \n", C2);
  126.     if(C3 != -9999)
  127.         fprintf(fff,
  128.                 "C3  %15.15lf \n", C3);
  129.     if(C4 != -9999)
  130.         fprintf(fff,
  131.                 "C4  %15.15lf \n", C4);
  132.     if(C5 != -9999)
  133.         fprintf(fff,
  134.                 "C5  %15.15lf \n", C5);
  135.     if(C6 != -9999)
  136.         fprintf(fff,
  137.                 "C6  %15.15lf \n", C6);
  138.     if(C7 != -9999)
  139.         fprintf(fff,
  140.                 "C7  %15.15lf \n", C7);
  141.     if(C8 != -9999)
  142.         fprintf(fff,
  143.                 "C8  %15.15lf \n", C8);
  144.     if(C9 != -9999)
  145.         fprintf(fff,
  146.                 "C9  %15.15lf \n", C9);
  147.     if(rho != -9999)
  148.         fprintf(fff,
  149.                 "R  %15.15lf /* rho */ \n", rho);
  150.     if(beta != -9999)
  151.         fprintf(fff,
  152.                 "beta %15.15lf \n", beta);
  153.     if(sigma != -9999)
  154.         fprintf(fff,
  155.                 "sigma  %15.15lf \n", sigma);
  156.     if(rho_final != rho)
  157.         fprintf(fff,
  158.                 "FR\n %15.15lf /* final rho */\n", rho_final);
  159.     if(rho_step != 1.)
  160.         fprintf(fff,
  161.                 "RS %15.15lf /* rho step */\n", rho_step);
  162.  
  163.     for(ss = 0; ss < 5; ss++)
  164.         if(xScrPix[ss] != -9999.&& xScrPix[ss] != 0 && yScrPix[ss] != 0) {
  165.                 /* they can't be 0 anyway */
  166.             x = X_Lo[ss];
  167.             X = X_Up[ss];
  168.             Y = Y_Up[ss];
  169.             yval = Y_Lo[ss];
  170.             fprintf(fff,
  171.                     "SSS  %d\n  %13.13lf %13.13lf %13.13lf %13.13lf \n          /* set window */\n"
  172.                     ,ss, x, X, yval, Y);
  173.             fprintf(fff,
  174.                     "       SS      %d /* window number */\nSD %15.15lf /* set diameter */\n"
  175.                     ,ss, diameters[ss]);
  176.             fprintf(fff,
  177.                     "C %d %d /* set coordinate numbers */\n", ssX_coord[ss], ssY_coord[ss]);
  178.         }
  179.  
  180.     if(OldDiameters != -9999)
  181.         fprintf(fff,
  182.                 "OSD  %15.15lf \n", OldDiameters);
  183.     if(screen_fraction !=.1)
  184.         fprintf(fff,
  185.                 "SF %15.15lf \n/* Screen Fraction = distance arrow keys move small arrow */\n",
  186.                 screen_fraction);
  187.  
  188.     if(x_old_low != -9999)
  189.         fprintf(fff, "OXL  %15.15lf \n", x_old_low);
  190.     if(x_old_upp != -9999)
  191.         fprintf(fff, "OXU  %15.15lf \n", x_old_upp);
  192.     if(y_old_low != -9999)
  193.         fprintf(fff, "OYL  %15.15lf \n", y_old_low);
  194.     if(y_old_upp != -9999)
  195.         fprintf(fff, "OYU  %15.15lf \n", y_old_upp);
  196.     if(x_new_low != -9999)
  197.         fprintf(fff, "NXL  %15.15lf \n", x_new_low);
  198.     if(x_new_upp != -9999)
  199.         fprintf(fff, "NXU  %15.15lf \n", x_new_upp);
  200.     if(y_new_low != -9999)
  201.         fprintf(fff, "NYL  %15.15lf \n", y_new_low);
  202.     if(y_new_upp != -9999)
  203.         fprintf(fff, "NYU  %15.15lf \n", y_new_upp);
  204.  
  205.     if(images != 0)
  206.         fprintf(fff,
  207.                 "IMAGES  %d \n", images);
  208.     if(its_per_plot != -9999 && its_per_plot != 1)
  209.         fprintf(fff,
  210.                 "IPP  %d /* iterates per plot */ \n", its_per_plot);
  211.     if(steps_per_cycle != -9999)
  212.         fprintf(fff,
  213.                 "SPC %lf /* differential equation steps per cycle of forcing function */\n"
  214.                 ,steps_per_cycle);
  215.     if(step != -9999 && step < 0)
  216.         fprintf(fff,
  217.                 "INVERT /* makes differential equation time step negative */ \n");
  218.     if(step != -9999)
  219.         fprintf(fff,
  220.                 "STEP  %15.15lf /* differential equation time step */ \n", step);
  221.     if(cycle != 0)
  222.         fprintf(fff,
  223.                 "PAUSE \n");
  224.     if(cross0flag != 0)
  225.         fprintf(fff,
  226.                 "CROSS /* plot cross at each dot */\n");
  227.     if(ticFlag != 0)
  228.         fprintf(fff,
  229.                 "TIC /* tic marks */ \n");
  230.     if(MaxChecks != 2000)
  231.         fprintf(fff,
  232.                 "MC  %d /* maximun number of checks */ \n", MaxChecks);
  233.     if(rad_attr !=.1)
  234.         fprintf(fff,
  235.                 "RA  %lf /* radius of attraction */\n", rad_attr);
  236.     if(IsClose !=.00000001)
  237.         fprintf(fff,
  238.                 "SDIST  %15.15lf /* straddle pair distance */ \n", IsClose);
  239.     if(BST_switch != 0)
  240.         fprintf(fff,
  241.                 "bstswitch  %d /* for Basin Straddle Trajectory */ \n", BST_switch);
  242.     if(divisions != 30)
  243.         fprintf(fff,
  244.                 "DIV  %d /* number of divisions in refining saddle straddle pair */\n"
  245.                 ,divisions);
  246.  
  247.     if(printer != 3)
  248.         fprintf(fff,
  249.                 "PT  %d /* set quantity of screen comments and printout data */ \n", printer);
  250.     if(onprint != 0)
  251.         fprintf(fff,
  252.                 "PH  %d /* number of times printer head strikes for each dot */\n", onprint);
  253.     fprintf(fff,
  254.             "SS  %d /* current window number */\n", ScrnSec);
  255.     fprintf(fff,
  256.             "XS  %15.15lf %15.15lf /* X Scale */ \n", X_lower, X_upper);
  257.     fprintf(fff,
  258.             "YS  %15.15lf %15.15lf /* Y Scale */  \n", Y_lower, Y_upper);
  259.     if(disk != 0)
  260.         fprintf(fff,
  261.                 "TDWP /* To DIsk When Printing */\n");
  262.     if(boxx != 0)
  263.         fprintf(fff,
  264.                 "DB /* draw box */\n");
  265.     if(plotFlag == 1)
  266.         fprintf(fff,
  267.                 "CONNECT \n");
  268.     if(period != 1)
  269.         fprintf(fff,
  270.                 "NP %d /* Newton Period */ \n", period);
  271.     fprintf(fff,
  272.             "DN %s /* Disk File name for saving pictures */ \n", DiskFileName);
  273.     fprintf(fff,
  274.             "f9 %d /* set color */ \n", color);
  275.  
  276.     if(frac != 0)
  277.         fprintf(fff,
  278.                 "FRAC  %15.15lf /* for stable and unstable manifolds */ \n", frac);
  279.     if(add != 0)
  280.         fprintf(fff,
  281.                 "ADD  %15.15lf /* for stable and unstable manifolds */ \n", add);
  282.     if(length != 0)
  283.         fprintf(fff,
  284.                 "LENGTH  %15.15lf /* for stable and unstable manifolds */ \n", length);
  285.     if(iter != 0)
  286.         fprintf(fff,
  287.                 "ITER  %d /* for stable and unstable manifolds */ \n", iter);
  288.     if(goodIterate != 0)
  289.         fprintf(fff,
  290.                 "GOODITERATE  %d /* for stable and unstable manifolds */ \n", goodIterate);
  291.     if(oldGoodIt != 0)
  292.         fprintf(fff,
  293.                 "OLDGOODIT  %d /* for stable and unstable manifolds */ \n", oldGoodIt);
  294.  
  295.     DumpYs(fff);
  296.     printTimes(fff);    /* for runtime and tdtime -- see Y.c */
  297.     bifdisk(fff);        /* in YBIFM.C for parameters for BIF */
  298.  
  299.     fprintf(fff,
  300.             "FileEnd\n");
  301. }
  302.  
  303. DumpYs(fff)            /* dumps to file fff all the non trivial
  304.                    coordinates of each yx[] for which yx[0] is
  305.                    non trivial */
  306. FILE * fff;
  307. {
  308.     char    x;
  309.     int     J,
  310.             K;
  311.  
  312.     scr_rowcol(0, 0);
  313.     K = NUM_Y;
  314.     for(J = 0; J < K; J++) {
  315.         x = '0' + J;
  316.         DumpDoubleVector(dim, x, fff);
  317.     }
  318.     for(J = 0; J < 5; J++) {
  319.         x = 'a' + J;
  320.         DumpDoubleVector(dim, x, fff);
  321.     }
  322. }
  323.  
  324. DumpDoubleVector(dimval, x, fff)    /* this routine takes a character x, and
  325.                    returns if yx[] does not exist; if it does
  326.                    exist and providing yx[0] != -9999., this
  327.                    routine transmits to file fff those
  328.                    coordinates of yx that are not equal to
  329.                    -9999.; when it does exist and is non
  330.                    trivial the routine starts transmission with
  331.                    SV<return>      x<return> and the rest of
  332.                    the transmissions are of the form i<return>
  333.                    Y[i]<return> and the string of transmissions
  334.                    ends with an extra <return> */
  335. int     dimval;
  336. char    x;
  337. FILE * fff;
  338. {
  339.     int     i,
  340.             dimen = dimval;
  341.  
  342.     if(dimval > eqn1 && x != '0')
  343.         dimen = eqn1;
  344.     if(num_lyap == 0 && lyapzero < dimen)
  345.         dimen = lyapzero;
  346.  
  347.     if(ChooseStorageVec (x) == 0)/* 0 means not acceptable */
  348.         return;
  349.  /* ChooseStorageVector sets pointer ystore_in */
  350.     if(ystore_in[0] == -9999.)
  351.         return;
  352.     else
  353.         fprintf(fff, "SV \n%c\n", StorChar);
  354.  
  355.  
  356.     for(i = 0; i < dimen; i++)
  357.         if(ystore_in[i] != -9999.)
  358.             fprintf(fff, "%d \n %15.15g \n", i, ystore_in[i]);
  359.  
  360.     fprintf(fff, "\n");    /* indicates end of coordinates */
  361. }
  362.